
Weather = { };

Weather.SnowFlakes = { };
Weather.MaxSnow = 250;
Weather.CurSnowCount = 0;

function Weather.GenerateFullSnow()
	
	for n = Weather.CurSnowCount, Weather.MaxSnow do
		
		Weather.AddSnowFlake( math.random( 0, 800 ), math.random( 0, 500 ) );
		
	end
	
end

function Weather.AddSnowFlake( x, y )
	
	table.insert( Weather.SnowFlakes, { enteredScreen = false, x = x, y = y, xVel = math.random( -30, 30 ), yVel = math.random( 100, 200 ) } );
			
	Weather.CurSnowCount = Weather.CurSnowCount + 1;
	
end

function Weather.DoSnow()

		
	while( Weather.CurSnowCount < Weather.MaxSnow ) do
			
		Weather.AddSnowFlake( math.random( 10, 800 ), math.random( -200, 0 ) );
			
	end
	
	Draw.BindTexture( "Graphics/pixel.png" );
	Draw.SetColor( 1, 1, 1, .8 );
		
	for k, v in pairs( Weather.SnowFlakes ) do
		
		v.x = v.x + v.xVel * GetDPS();
		v.y = v.y + v.yVel * GetDPS();
		
		Draw.Texture( nil, v.x, v.y, 4, 4 );

		if( v.y > 600 ) then

			Weather.SnowFlakes[k] = nil;
			Weather.CurSnowCount = Weather.CurSnowCount - 1;
			
		end
		
		if( not v.enteredScreen and ( v.x > 0 and v.x < 800 and v.y > 0 and v.y < 600 ) ) then
			
			v.enteredScreen = true;
			
		end
		
	end
	
end